package
{
  public class Training
  {
    private static const combos:Array = [ {label:"Strength",   data:[0,0,0,1,0,0,0,1,1,1,0,1,1,1]},
                                {label:"Speed",      data:[0,0,1,0,1,0,0,0,1,0,0,0,0,0]},
                                {label:"Agility",    data:[0,1,0,0,1,1,0,1,1,1,0,0,0,0]},
                                {label:"Jumping",    data:[1,0,0,0,1,1,0,0,1,0,1,0,0,0]},
                                {label:"Stamina",    data:[0,1,1,1,0,0,1,0,0,0,0,0,0,0]},
                                {label:"Vision",     data:[0,0,1,1,0,0,1,0,0,1,1,0,1,1]},
                                {label:"Confidence", data:[0,0,0,0,1,1,0,0,0,0,0,1,0,0]},
                                {label:"Blocking",   data:[1,0,1,0,0,0,0,0,0,0,0,0,0,0]},
                                {label:"Tackling",   data:[1,1,1,1,0,0,0,0,0,0,0,0,0,0]},
                                {label:"Throwing",   data:[1,0,1,0,0,1,0,0,0,0,0,0,0,0]},
                                {label:"Catching",   data:[0,0,0,1,0,1,0,0,0,0,0,1,0,0]},
                                {label:"Carrying",   data:[1,0,0,0,0,0,1,0,0,0,1,0,0,0]},
                                {label:"Punting",    data:[1,0,0,0,0,1,0,0,0,0,0,0,0,0]},
                                {label:"Kicking",    data:[1,0,0,0,0,1,0,0,0,0,0,0,0,0]}
                              ];
    
    private static const trainingTable:Array = [{ lvl:7,   nrm:60,  int:75  },
                                      { lvl:8,   nrm:57,  int:71  },
                                      { lvl:9,   nrm:55,  int:69  },
                                      { lvl:10,  nrm:53,  int:66  },
                                      { lvl:11,  nrm:51,  int:64  },
                                      { lvl:12,  nrm:49,  int:61  },
                                      { lvl:13,  nrm:48,  int:60  },
                                      { lvl:14,  nrm:46,  int:58  },
                                      { lvl:15,  nrm:44,  int:55  },
                                      { lvl:16,  nrm:42,  int:53  },
                                      { lvl:17,  nrm:41,  int:51  },
                                      { lvl:18,  nrm:39,  int:49  },
                                      { lvl:19,  nrm:38,  int:48  },
                                      { lvl:20,  nrm:36,  int:45  },
                                      { lvl:21,  nrm:35,  int:44  },
                                      { lvl:22,  nrm:34,  int:43  },
                                      { lvl:23,  nrm:33,  int:41  },
                                      { lvl:24,  nrm:31,  int:39  },
                                      { lvl:25,  nrm:30,  int:38  },
                                      { lvl:26,  nrm:29,  int:36  },
                                      { lvl:27,  nrm:28,  int:35  },
                                      { lvl:28,  nrm:27,  int:34  },
                                      { lvl:29,  nrm:26,  int:33  },
                                      { lvl:30,  nrm:25,  int:31  },
                                      { lvl:31,  nrm:24,  int:30  },
                                      { lvl:32,  nrm:23,  int:29  },
                                      { lvl:33,  nrm:22,  int:28  },
                                      { lvl:34,  nrm:21,  int:26  },
                                      { lvl:35,  nrm:20,  int:25  },
                                      { lvl:36,  nrm:19,  int:24  },
                                      { lvl:37,  nrm:19,  int:24  },
                                      { lvl:38,  nrm:18,  int:23  },
                                      { lvl:39,  nrm:17,  int:21  },
                                      { lvl:40,  nrm:17,  int:21  },
                                      { lvl:41,  nrm:16,  int:20  },
                                      { lvl:42,  nrm:15,  int:19  },
                                      { lvl:43,  nrm:15,  int:19  },
                                      { lvl:44,  nrm:14,  int:18  },
                                      { lvl:45,  nrm:14,  int:18  },
                                      { lvl:46,  nrm:13,  int:16  },
                                      { lvl:47,  nrm:13,  int:16  },
                                      { lvl:48,  nrm:12,  int:15  },
                                      { lvl:49,  nrm:12,  int:15  },
                                      { lvl:50,  nrm:11,  int:14  },
                                      { lvl:51,  nrm:11,  int:14  },
                                      { lvl:52,  nrm:11,  int:14  },
                                      { lvl:53,  nrm:10,  int:13  },
                                      { lvl:54,  nrm:9,  int:11  },
                                      { lvl:55,  nrm:9,  int:11  },
                                      { lvl:56,  nrm:9,  int:11  },
                                      { lvl:57,  nrm:8,  int:10  },
                                      { lvl:58,  nrm:8,  int:10  },
                                      { lvl:59,  nrm:8,  int:10  },
                                      { lvl:60,  nrm:8,  int:10  },
                                      { lvl:61,  nrm:8,  int:10  },
                                      { lvl:62,  nrm:7,  int:9  },
                                      { lvl:63,  nrm:7,  int:9  },
                                      { lvl:64,  nrm:7,  int:9  },
                                      { lvl:65,  nrm:7,  int:9  },
                                      { lvl:66,  nrm:6,  int:8  },
                                      { lvl:67,  nrm:6,  int:8  },
                                      { lvl:68,  nrm:6,  int:8  },
                                      { lvl:69,  nrm:5,  int:6  },
                                      { lvl:70,  nrm:5,  int:6  },
                                      { lvl:71,  nrm:5,  int:6  },
                                      { lvl:72,  nrm:5,  int:6  },
                                      { lvl:73,  nrm:5,  int:6  },
                                      { lvl:74,  nrm:5,  int:6  },
                                      { lvl:75,  nrm:4,  int:5  },
                                      { lvl:76,  nrm:4,  int:5  },
                                      { lvl:77,  nrm:4,  int:5  },
                                      { lvl:78,  nrm:4,  int:5  },
                                      { lvl:79,  nrm:4,  int:5  },
                                      { lvl:80,  nrm:4,  int:5  },
                                      { lvl:81,  nrm:3,  int:4  },
                                      { lvl:82,  nrm:3,  int:4  },
                                      { lvl:83,  nrm:3,  int:4  },
                                      { lvl:84,  nrm:3,  int:4  },
                                      { lvl:85,  nrm:2,  int:3  },
                                      { lvl:86,  nrm:2,  int:3  },
                                      { lvl:87,  nrm:2,  int:3  },
                                      { lvl:88,  nrm:2,  int:3  },
                                      { lvl:89,  nrm:2,  int:3  },
                                      { lvl:90,  nrm:2,  int:3  }
                                     ];
    [Bindable]
    public var str:uint = 0;

    [Bindable]
    public var spd:uint = 0;

    [Bindable]
    public var agi:uint = 0;

    [Bindable]
    public var jmp:uint = 0;
    
    [Bindable]
    public var sta:uint = 0;

    [Bindable]
    public var vis:uint = 0;

    [Bindable]
    public var con:uint = 0;

    [Bindable]
    public var blk:uint = 0;

    [Bindable]
    public var tak:uint = 0;

    [Bindable]
    public var thr:uint = 0;

    [Bindable]
    public var cth:uint = 0;
    
    [Bindable]
    public var car:uint = 0;
    
    [Bindable]
    public var kck:uint = 0;
    
    [Bindable]
    public var pnt:uint = 0;

    [Bindable]
    public var ity:String = "Normal + Activity";
    
    [Bindable]
    public var atr1:String = "Strength";
    
    [Bindable]
    public var atr2:String = "";

    public static function getTraining( n:uint, intense:Boolean, bonus:Boolean = false ):uint
    {
      var i:uint = n / 100;
      
      if ( i < 8 )
        return 1;
        
      for each ( var obj:Object in trainingTable )
      {
        if ( obj.lvl == i )
        {
          if ( intense )
            return obj.int;
          else if ( bonus )
            return obj.nrm * 1.075;
          else
            return obj.nrm;
        }
      }
      
      return 0;
    }
    
    public static function getPoints():uint
    {
      return 2;
    }

    public function Training():void{}

    public function getCombos( stat:String ):Array
    {
      var ret:Array = [];
      
      for each ( var obj:Object in combos )
      {
        if ( obj.label == stat )
        {
          for ( var i:uint = 0; i < 14; i++ )
          {
            if ( obj.data[i] == 1 )
              ret.push( combos[i].label );
          }
          return ret;
        }
      }
      return null;
    }
      
    public function getStat( s:String ):uint
    {
      switch( s )
      {
        case "Strength":   return str;
        case "Speed":      return spd;
        case "Agility":    return agi;
        case "Jumping":    return jmp;
        case "Stamina":    return sta;
        case "Vision":     return vis;
        case "Strength":   return str;
        case "Confidence": return con;
        case "Blocking":   return blk;
        case "Tackling":   return tak;
        case "Throwing":   return thr;
        case "Catching":   return cth;
        case "Carrying":   return car;
        case "Kicking":    return kck;
        case "Punting":    return pnt;
        default:           return 0;
      }
    }
  
    public function setStat( s:String, n:uint ):void
    {
      switch( s )
      {
        case "Strength":   str = n;
                           return;
        case "Speed":      spd = n;
                           return;
        case "Agility":    agi = n;
                           return;
        case "Jumping":    jmp = n;
                           return;
        case "Stamina":    sta = n;
                           return;
        case "Vision":     vis = n;
                           return;
        case "Strength":   str = n;
                           return;
        case "Confidence": con = n;
                           return;
        case "Blocking":   blk = n;
                           return;
        case "Tackling":   tak = n;
                           return;
        case "Throwing":   thr = n;
                           return;
        case "Catching":   cth = n;
                           return;
        case "Carrying":   car = n;
                           return;
        case "Kicking":    kck = n;
                           return;
        case "Punting":    pnt = n;
                           return;
      }
    }
    
    public function copy( t:Training ):void
    {
      str  = t.str;
      spd  = t.spd;
      agi  = t.agi;
      jmp  = t.jmp;
      sta  = t.sta;
      vis  = t.vis;
      con  = t.con;
      blk  = t.blk;
      tak  = t.tak;
      thr  = t.thr;
      cth  = t.cth;
      car  = t.car;
      kck  = t.kck;
      pnt  = t.pnt;
      ity  = t.ity;
      atr1 = t.atr1;
      atr2 = t.atr2;
    }
  }
}